package com.taptech.doufu.bean.cartoon;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

import java.lang.reflect.Type;

/**
 * Created by Wyatt on 2017/9/16/016.
 */

public class RedaStatusDeserializer implements JsonDeserializer<ReadStatus> {

    @Override
    public ReadStatus deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        ReadStatus readStatus = new ReadStatus();
        if (json.isJsonObject()) {
            JsonObject jsonObject = json.getAsJsonObject();
            readStatus.setChapter_id(jsonObject.get("chapter_id").getAsString());
            readStatus.setIndex(jsonObject.get("index").getAsInt());
        }
        return readStatus;
    }
}